Skip to content

Commit

Permalink
merge branch 'master' into rnmobile/fix-title-no-focus
Browse files Browse the repository at this point in the history
  • Loading branch information
etoledom committed Apr 19, 2019
2 parents 360d1b8 + afce486 commit 53a9e94
Show file tree
Hide file tree
Showing 117 changed files with 3,125 additions and 2,150 deletions.
32 changes: 27 additions & 5 deletions docs/designers-developers/developers/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,17 @@ saved state of the post.

Post attribute value.

### getAutosaveAttribute
### getAutosaveAttribute (deprecated)

Returns an attribute value of the current autosave revision for a post, or
null if there is no autosave for the post.

*Deprecated*

Deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
from the '@wordpress/core-data' package and access properties on the returned
autosave object using getPostRawValue.

*Parameters*

* state: Global application state.
Expand Down Expand Up @@ -303,17 +309,23 @@ Returns true if the post can be autosaved, or false otherwise.
*Parameters*

* state: Global application state.
* autosave: A raw autosave object from the REST API.

*Returns*

Whether the post can be autosaved.

### getAutosave
### getAutosave (deprecated)

Returns the current autosave, or null if one is not set (i.e. if the post
has yet to be autosaved, or has been saved or published since the last
autosave).

*Deprecated*

Deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )`
selector from the '@wordpress/core-data' package.

*Parameters*

* state: Editor state.
Expand All @@ -322,10 +334,15 @@ autosave).

Current autosave, if exists.

### hasAutosave
### hasAutosave (deprecated)

Returns the true if there is an existing autosave, otherwise false.

*Deprecated*

Deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
from the '@wordpress/core-data' package and check for a truthy value.

*Parameters*

* state: Global application state.
Expand Down Expand Up @@ -752,14 +769,19 @@ post has been received, either by initialization or save.

* post: Post object.

### resetAutosave
### resetAutosave (deprecated)

Returns an action object used in signalling that the latest autosave of the
post has been received, by initialization or autosave.

*Deprecated*

Deprecated since 5.6. Callers should use the `receiveAutosaves( postId, autosave )`
selector from the '@wordpress/core-data' package.

*Parameters*

* post: Autosave post object.
* newAutosave: Autosave post object.

### __experimentalRequestPostUpdateStart

Expand Down
78 changes: 77 additions & 1 deletion docs/designers-developers/developers/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ Returns all available authors.

Authors list.

### getCurrentUser

Returns the current user.

*Parameters*

* state: Data state.

*Returns*

Current user object.

### getUserQueryResults

Returns all the users returned by a query ID.
Expand Down Expand Up @@ -181,6 +193,52 @@ https://developer.wordpress.org/rest-api/reference/
Whether or not the user can perform the action,
or `undefined` if the OPTIONS request is still being made.

### getAutosaves

Returns the latest autosaves for the post.

May return multiple autosaves since the backend stores one autosave per
author for each post.

*Parameters*

* state: State tree.
* postType: The type of the parent post.
* postId: The id of the parent post.

*Returns*

An array of autosaves for the post, or undefined if there is none.

### getAutosave

Returns the autosave for the post and author.

*Parameters*

* state: State tree.
* postType: The type of the parent post.
* postId: The id of the parent post.
* authorId: The id of the author.

*Returns*

The autosave for the post and author.

### hasFetchedAutosaves

Returns true if the REST request for autosaves has completed.

*Parameters*

* state: State tree.
* postType: The type of the parent post.
* postId: The id of the parent post.

*Returns*

True if the REST request was completed. False otherwise.

## Actions

### receiveUserQuery
Expand All @@ -192,6 +250,14 @@ Returns an action object used in signalling that authors have been received.
* queryID: Query ID.
* users: Users received.

### receiveCurrentUser

Returns an action used in signalling that the current user has been received.

*Parameters*

* currentUser: Current user object.

### addEntities

Returns an action object used in adding new entities.
Expand Down Expand Up @@ -256,4 +322,14 @@ permission to perform an action on a REST resource.
*Parameters*

* key: A key that represents the action and REST resource.
* isAllowed: Whether or not the user can perform the action.
* isAllowed: Whether or not the user can perform the action.

### receiveAutosaves

Returns an action object used in signalling that the autosaves for a
post have been received.

*Parameters*

* postId: The id of the post that is parent to the autosave.
* autosaves: An array of autosaves or singular autosave object.
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": "2.0.0",
"version": "2.0.1",
"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.4.3",
"version": "2.4.4",
"description": "Block library for the WordPress editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
112 changes: 112 additions & 0 deletions packages/block-library/src/button/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* External dependencies
*/
import { omit } from 'lodash';

/**
* WordPress dependencies
*/
import { RichText } from '@wordpress/block-editor';

const colorsMigration = ( attributes ) => {
return omit( {
...attributes,
customTextColor: attributes.textColor && '#' === attributes.textColor[ 0 ] ? attributes.textColor : undefined,
customBackgroundColor: attributes.color && '#' === attributes.color[ 0 ] ? attributes.color : undefined,
}, [ 'color', 'textColor' ] );
};

const blockAttributes = {
url: {
type: 'string',
source: 'attribute',
selector: 'a',
attribute: 'href',
},
title: {
type: 'string',
source: 'attribute',
selector: 'a',
attribute: 'title',
},
text: {
type: 'string',
source: 'html',
selector: 'a',
},
};

const deprecated = [
{
attributes: {
...blockAttributes,
color: {
type: 'string',
},
textColor: {
type: 'string',
},
align: {
type: 'string',
default: 'none',
},
},
save( { attributes } ) {
const { url, text, title, align, color, textColor } = attributes;

const buttonStyle = {
backgroundColor: color,
color: textColor,
};

const linkClass = 'wp-block-button__link';

return (
<div className={ `align${ align }` }>
<RichText.Content
tagName="a"
className={ linkClass }
href={ url }
title={ title }
style={ buttonStyle }
value={ text }
/>
</div>
);
},
migrate: colorsMigration,
},
{
attributes: {
...blockAttributes,
color: {
type: 'string',
},
textColor: {
type: 'string',
},
align: {
type: 'string',
default: 'none',
},
},
save( { attributes } ) {
const { url, text, title, align, color, textColor } = attributes;

return (
<div className={ `align${ align }` } style={ { backgroundColor: color } }>
<RichText.Content
tagName="a"
href={ url }
title={ title }
style={ { color: textColor } }
value={ text }
/>
</div>
);
},
migrate: colorsMigration,
},
];

export default deprecated;
Loading

0 comments on commit 53a9e94

Please sign in to comment.