Skip to content

Commit

Permalink
Try: New default rendering mode for editor via post type supports
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jan 8, 2025
1 parent 54f59fe commit 5b395f0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 146 deletions.

This file was deleted.

60 changes: 0 additions & 60 deletions lib/compat/wordpress-6.8/post.php

This file was deleted.

15 changes: 0 additions & 15 deletions lib/compat/wordpress-6.8/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@
* @package gutenberg
*/

if ( ! defined( 'ABSPATH' ) ) {
die( 'Silence is golden.' );
}

if ( ! function_exists( 'gutenberg_add_post_type_rendering_mode' ) ) {
/**
* Add Block Editor default rendering mode to the post type response.
*/
function gutenberg_add_post_type_rendering_mode() {
$controller = new Gutenberg_REST_Post_Types_Controller_6_8();
$controller->register_routes();
}
}
add_action( 'rest_api_init', 'gutenberg_add_post_type_rendering_mode' );

// When querying terms for a given taxonomy in the REST API, respect the default
// query arguments set for that taxonomy upon registration.
function gutenberg_respect_taxonomy_default_args_in_rest_api( $args ) {
Expand Down
2 changes: 0 additions & 2 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function gutenberg_is_experiment_enabled( $name ) {
// WordPress 6.8 compat.
require __DIR__ . '/compat/wordpress-6.8/block-comments.php';
require __DIR__ . '/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php';
require __DIR__ . '/compat/wordpress-6.8/class-gutenberg-rest-post-types-controller-6-8.php';
require __DIR__ . '/compat/wordpress-6.8/class-gutenberg-hierarchical-sort.php';
require __DIR__ . '/compat/wordpress-6.8/rest-api.php';

Expand Down Expand Up @@ -98,7 +97,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.8/preload.php';
require __DIR__ . '/compat/wordpress-6.8/blocks.php';
require __DIR__ . '/compat/wordpress-6.8/functions.php';
require __DIR__ . '/compat/wordpress-6.8/post.php';
require __DIR__ . '/compat/wordpress-6.8/site-editor.php';
require __DIR__ . '/compat/wordpress-6.8/class-gutenberg-rest-user-controller.php';

Expand Down
24 changes: 16 additions & 8 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,32 @@ export const ExperimentalEditorProvider = withRegistryProvider(
getRenderingMode,
__unstableIsEditorReady,
} = select( editorStore );
const { getEntitiesConfig } = select( coreStore );
const {
getEntitiesConfig,
getPostType,
hasFinishedResolution,
} = select( coreStore );

const postTypeObject = select( coreStore ).getPostType(
post.type
const postTypeSupports = getPostType( post.type )?.supports;
const _hasLoadedPostObject = hasFinishedResolution(
'getPostType',
[ post.type ]
);

const _hasLoadedPostObject = select(
coreStore
).hasFinishedResolution( 'getPostType', [ post.type ] );
const _defaultMode = Array.isArray( postTypeSupports?.editor )
? postTypeSupports.editor.find(
( features ) => 'default_mode' in features
)?.default_mode
: undefined;

return {
hasLoadedPostObject: _hasLoadedPostObject,
editorSettings: getEditorSettings(),
isReady: __unstableIsEditorReady(),
mode: getRenderingMode(),
defaultMode:
hasTemplate && postTypeObject?.default_rendering_mode
? postTypeObject?.default_rendering_mode
hasTemplate && _defaultMode
? _defaultMode
: 'post-only',
selection: getEditorSelection(),
postTypeEntities:
Expand Down

0 comments on commit 5b395f0

Please sign in to comment.