Skip to content

Commit

Permalink
Merge branch 'master' into add/entity-provider-and-refactor-custom-so…
Browse files Browse the repository at this point in the history
…urces
  • Loading branch information
felixarntz committed Sep 18, 2019
2 parents 7e1b750 + e7d4237 commit eedc6e9
Show file tree
Hide file tree
Showing 56 changed files with 513 additions and 73 deletions.
2 changes: 2 additions & 0 deletions docs/designers-developers/developers/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ _Related_

<a name="getReferenceByDistinctEdits" href="#getReferenceByDistinctEdits">#</a> **getReferenceByDistinctEdits**

> **Deprecated** since Gutenberg 6.5.0.
Returns a new reference when edited values have changed. This is useful in
inferring where an edit has been made between states by comparison of the
return values using strict equality.
Expand Down
21 changes: 21 additions & 0 deletions docs/designers-developers/developers/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,27 @@ _Returns_

- `?Object`: The edit.

<a name="getReferenceByDistinctEdits" href="#getReferenceByDistinctEdits">#</a> **getReferenceByDistinctEdits**

Returns a new reference when edited values have changed. This is useful in
inferring where an edit has been made between states by comparison of the
return values using strict equality.

_Usage_

const hasEditOccurred = (
getReferenceByDistinctEdits( beforeState ) !==
getReferenceByDistinctEdits( afterState )
);

_Parameters_

- _state_ `Object`: Editor state.

_Returns_

- `*`: A value whose reference will change only when an edit occurs.

<a name="getThemeSupports" href="#getThemeSupports">#</a> **getThemeSupports**

Return theme supports data in the index.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It turns out that writing the simplest possible block which contains only static
- [zgordon/gutenberg-course](https://github.com/zgordon/gutenberg-course) - a repository for Zac Gordon's Gutenberg Development Course
- [ahmadawais/create-guten-block](https://github.com/ahmadawais/create-guten-block) - A zero-configuration developer toolkit for building WordPress Gutenberg block plugins

It might be also a good idea to browse the folder with [all core blocks](/packages/block-library/src) to see how they are implemented.
It might be also a good idea to browse the folder with [all core blocks](https://github.com/WordPress/gutenberg/tree/master/packages/block-library/src) to see how they are implemented.

## WP-CLI

Expand Down
2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Gutenberg
* Plugin URI: https://github.com/WordPress/gutenberg
* Description: Printing since 1440. This is the development plugin for the new block editor in core.
* Version: 6.4.0
* Version: 6.5.0-rc.1
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "6.4.0",
"version": "6.5.0-rc.1",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
2 changes: 1 addition & 1 deletion packages/annotations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/annotations",
"version": "1.6.0",
"version": "1.7.0",
"description": "Annotate content in the Gutenberg editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/api-fetch",
"version": "3.5.0",
"version": "3.6.0",
"description": "Utility to make WordPress REST API requests.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-default/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/babel-preset-default",
"version": "4.5.0",
"version": "4.6.0",
"description": "Default Babel preset for WordPress development.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-directory/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Master
## 1.0.0 (2019-09-16)

- Initial release.
4 changes: 2 additions & 2 deletions packages/block-directory/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@wordpress/block-directory",
"version": "1.0.0-alpha.0",
"version": "1.0.0",
"description": "Extend editor with block directory features to search, download and install blocks.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"keywords": [
"wordpress",
"wordpress",
"block directory"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/block-directory/README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-editor",
"version": "3.1.0",
"version": "3.2.0",
"description": "Generic block editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-library",
"version": "2.8.0",
"version": "2.9.0",
"description": "Block library for the WordPress editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/blocks",
"version": "6.6.0",
"version": "6.7.0",
"description": "Block API for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/components",
"version": "8.2.0",
"version": "8.3.0",
"description": "UI components for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/compose/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/compose",
"version": "3.6.0",
"version": "3.7.0",
"description": "WordPress higher-order components (HOCs).",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
21 changes: 21 additions & 0 deletions packages/core-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,27 @@ _Returns_

- `?Object`: The edit.

<a name="getReferenceByDistinctEdits" href="#getReferenceByDistinctEdits">#</a> **getReferenceByDistinctEdits**

Returns a new reference when edited values have changed. This is useful in
inferring where an edit has been made between states by comparison of the
return values using strict equality.

_Usage_

const hasEditOccurred = (
getReferenceByDistinctEdits( beforeState ) !==
getReferenceByDistinctEdits( afterState )
);

_Parameters_

- _state_ `Object`: Editor state.

_Returns_

- `*`: A value whose reference will change only when an edit occurs.

<a name="getThemeSupports" href="#getThemeSupports">#</a> **getThemeSupports**

Return theme supports data in the index.
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/core-data",
"version": "2.6.0",
"version": "2.7.0",
"description": "Access to and manipulation of core WordPress entities.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
23 changes: 23 additions & 0 deletions packages/core-data/src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,3 +478,26 @@ export function getAutosave( state, postType, postId, authorId ) {
export const hasFetchedAutosaves = createRegistrySelector( ( select ) => ( state, postType, postId ) => {
return select( REDUCER_KEY ).hasFinishedResolution( 'getAutosaves', [ postType, postId ] );
} );

/**
* Returns a new reference when edited values have changed. This is useful in
* inferring where an edit has been made between states by comparison of the
* return values using strict equality.
*
* @example
*
* ```
* const hasEditOccurred = (
* getReferenceByDistinctEdits( beforeState ) !==
* getReferenceByDistinctEdits( afterState )
* );
* ```
*
* @param {Object} state Editor state.
*
* @return {*} A value whose reference will change only when an edit occurs.
*/
export const getReferenceByDistinctEdits = createSelector(
() => [],
( state ) => [ state.undo.length, state.undo.offset ],
);
43 changes: 43 additions & 0 deletions packages/core-data/src/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getAutosave,
getAutosaves,
getCurrentUser,
getReferenceByDistinctEdits,
} from '../selectors';

describe( 'getEntityRecord', () => {
Expand Down Expand Up @@ -275,3 +276,45 @@ describe( 'getCurrentUser', () => {
expect( getCurrentUser( state ) ).toEqual( currentUser );
} );
} );

describe( 'getReferenceByDistinctEdits', () => {
it( 'should return referentially equal values across empty states', () => {
const state = { undo: [] };
expect( getReferenceByDistinctEdits( state ) ).toBe( getReferenceByDistinctEdits( state ) );

const beforeState = { undo: [] };
const afterState = { undo: [] };
expect( getReferenceByDistinctEdits( beforeState ) ).toBe( getReferenceByDistinctEdits( afterState ) );
} );

it( 'should return referentially equal values across unchanging non-empty state', () => {
const undoStates = [ {} ];
const state = { undo: undoStates };
expect( getReferenceByDistinctEdits( state ) ).toBe( getReferenceByDistinctEdits( state ) );

const beforeState = { undo: undoStates };
const afterState = { undo: undoStates };
expect( getReferenceByDistinctEdits( beforeState ) ).toBe( getReferenceByDistinctEdits( afterState ) );
} );

describe( 'when adding edits', () => {
it( 'should return referentially different values across changing states', () => {
const beforeState = { undo: [ {} ] };
beforeState.undo.offset = 0;
const afterState = { undo: [ {}, {} ] };
afterState.undo.offset = 1;
expect( getReferenceByDistinctEdits( beforeState ) ).not.toBe( getReferenceByDistinctEdits( afterState ) );
} );
} );

describe( 'when using undo', () => {
it( 'should return referentially different values across changing states', () => {
const beforeState = { undo: [ {}, {} ] };
beforeState.undo.offset = 1;
const afterState = { undo: [ {}, {} ] };
afterState.undo.offset = 0;
expect( getReferenceByDistinctEdits( beforeState ) ).not.toBe( getReferenceByDistinctEdits( afterState ) );
} );
} );
} );

2 changes: 1 addition & 1 deletion packages/data-controls/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/data-controls",
"version": "1.2.0",
"version": "1.3.0",
"description": "A set of common controls for the @wordpress/data api.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/data",
"version": "4.8.0",
"version": "4.9.0",
"description": "Data module for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/dependency-extraction-webpack-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Master
## 2.0.0 (2019-09-16)

### Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion packages/dependency-extraction-webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/dependency-extraction-webpack-plugin",
"version": "1.2.0",
"version": "2.0.0",
"description": "Extract WordPress script dependencies from webpack bundles.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-test-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/e2e-test-utils",
"version": "2.3.0",
"version": "2.4.0",
"description": "End-To-End (E2E) test utils for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Master
## 1.7.0 (2019-09-16)

## 1.6.0 (2019-09-03)

Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/e2e-tests",
"version": "1.6.0",
"version": "1.7.0",
"description": "End-To-End (E2E) tests for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
Loading

0 comments on commit eedc6e9

Please sign in to comment.