Skip to content

Commit

Permalink
Introduce a new 'Extending Editor' document specific to Editor filters (
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber authored and gziolo committed Aug 2, 2018
1 parent cce4232 commit dd44862
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
14 changes: 0 additions & 14 deletions docs/extensibility/extending-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,6 @@ var withDataAlign = wp.compose.createHigherOrderComponent( function( BlockListBl
wp.hooks.addFilter( 'editor.BlockListBlock', 'my-plugin/with-data-align', withDataAlign );
```

### `editor.PostFeaturedImage.imageSize`

Used to modify the image size displayed in the Post Featured Image component. It defaults to `'post-thumbnail'`, and will fail back to the `full` image size when the specified image size doesn't exist in the media object. It's modeled after the `admin_post_thumbnail_size` filter in the Classic Editor.

_Example:_

```
var withImageSize = function( size, mediaId, postId ) {
return 'large';
};
wp.hooks.addFilter( 'editor.PostFeaturedImage.imageSize', 'my-plugin/with-image-size', withImageSize );
```

## Removing Blocks

### Using a blacklist
Expand Down
21 changes: 21 additions & 0 deletions docs/extensibility/extending-editor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Extending Editor (Experimental)

[Hooks](https://developer.wordpress.org/plugins/hooks/) are a way for one piece of code to interact/modify another piece of code. They make up the foundation for how plugins and themes interact with Gutenberg, but they’re also used extensively by WordPress Core itself. There are two types of hooks: [Actions](https://developer.wordpress.org/plugins/hooks/actions/) and [Filters](https://developer.wordpress.org/plugins/hooks/filters/). They were initially implemented in PHP, but for the purpose of Gutenberg they were ported to JavaScript and published to npm as [@wordpress/hooks](https://www.npmjs.com/package/@wordpress/hooks) package for general purpose use. You can also learn more about both APIs: [PHP](https://codex.wordpress.org/Plugin_API/) and [JavaScript](https://github.com/WordPress/packages/tree/master/packages/hooks).

## Modifying Editor

To modify the behavior of the editor experience, Gutenberg exposes the following Filters:

### `editor.PostFeaturedImage.imageSize`

Used to modify the image size displayed in the Post Featured Image component. It defaults to `'post-thumbnail'`, and will fail back to the `full` image size when the specified image size doesn't exist in the media object. It's modeled after the `admin_post_thumbnail_size` filter in the Classic Editor.

_Example:_

```
var withImageSize = function( size, mediaId, postId ) {
return 'large';
};
wp.hooks.addFilter( 'editor.PostFeaturedImage.imageSize', 'my-plugin/with-image-size', withImageSize );
```
6 changes: 6 additions & 0 deletions docs/root-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
"markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/extending-blocks.md",
"parent": "extensibility"
},
{
"title": "Extending Editor",
"slug": "extending-editor",
"markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/extending-editor.md",
"parent": "extensibility"
},
{
"title": "Meta Boxes",
"slug": "meta-box",
Expand Down

0 comments on commit dd44862

Please sign in to comment.