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

WIP: Blocks: Reimplement shared block as embedded editor #7453

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
123 changes: 0 additions & 123 deletions lib/class-wp-rest-blocks-controller.php

This file was deleted.

1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// These files only need to be loaded if within a rest server instance
// which this class will exist if that is the case.
if ( class_exists( 'WP_REST_Controller' ) ) {
require dirname( __FILE__ ) . '/class-wp-rest-blocks-controller.php';
require dirname( __FILE__ ) . '/class-wp-rest-autosaves-controller.php';
require dirname( __FILE__ ) . '/class-wp-rest-block-renderer-controller.php';
require dirname( __FILE__ ) . '/class-wp-rest-search-controller.php';
Expand Down
15 changes: 7 additions & 8 deletions lib/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,21 +461,20 @@ function gutenberg_register_post_types() {
register_post_type(
'wp_block',
array(
'labels' => array(
'labels' => array(
'name' => 'Blocks',
'singular_name' => 'Block',
),
'public' => false,
'rewrite' => false,
'show_in_rest' => true,
'rest_base' => 'blocks',
'rest_controller_class' => 'WP_REST_Blocks_Controller',
'capability_type' => 'block',
'public' => false,
'rewrite' => false,
'show_in_rest' => true,
'rest_base' => 'blocks',
'capability_type' => 'block',
'capabilities' => array(
'read' => 'read_blocks',
'create_posts' => 'create_blocks',
),
'map_meta_cap' => true,
'map_meta_cap' => true,
)
);

Expand Down
39 changes: 37 additions & 2 deletions packages/block-library/src/block/edit-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Button } from '@wordpress/components';
import { Component, Fragment, createRef } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { ESCAPE } from '@wordpress/keycodes';
import { withInstanceId } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { withInstanceId, compose } from '@wordpress/compose';

class ReusableBlockEditPanel extends Component {
constructor() {
Expand Down Expand Up @@ -115,4 +116,38 @@ class ReusableBlockEditPanel extends Component {
}
}

export default withInstanceId( ReusableBlockEditPanel );
export default compose( [
withInstanceId,
withSelect( ( select ) => {
const { getEditedPostAttribute, isSavingPost } = select( 'core/editor' );

return {
title: getEditedPostAttribute( 'title' ),
isSaving: isSavingPost(),
};
} ),
withDispatch( ( dispatch, ownProps ) => {
const {
editPost,
undoAll,
savePost,
clearSelectedBlock,
} = dispatch( 'core/editor' );

return {
onChangeTitle( title ) {
editPost( { title } );
},
onSave() {
clearSelectedBlock();
savePost();
ownProps.onSave();
},
onCancel() {
clearSelectedBlock();
undoAll();
ownProps.onCancel();
},
};
} ),
] )( ReusableBlockEditPanel );
Loading