Skip to content

Commit

Permalink
[Block Editor]: Lock __experimentalBlockInspectorAnimation setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Feb 3, 2023
1 parent 12fcb43 commit 42cf442
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,6 @@ public function get_item_schema() {
'context' => array( 'mobile' ),
),

'__experimentalBlockInspectorAnimation' => array(
'description' => __( 'Whether to enable animation when showing and hiding the block inspector.', 'gutenberg' ),
'type' => 'object',
'context' => array( 'site-editor' ),
),

'alignWide' => array(
'description' => __( 'Enable/Disable Wide/Full Alignments.', 'gutenberg' ),
'type' => 'boolean',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {
if ( blockType ) {
const globalBlockInspectorAnimationSettings =
select( blockEditorStore ).getSettings()
.__experimentalBlockInspectorAnimation;
.blockInspectorAnimation;
return globalBlockInspectorAnimationSettings?.[
blockType.name
];
Expand Down
7 changes: 7 additions & 0 deletions packages/block-editor/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ export const SETTINGS_DEFAULTS = {
__unstableGalleryWithImageBlocks: false,
__unstableIsPreviewMode: false,

// This setting is `private` now with `lock` API.
blockInspectorAnimation: {
'core/navigation': { enterDirection: 'leftToRight' },
'core/navigation-submenu': { enterDirection: 'rightToLeft' },
'core/navigation-link': { enterDirection: 'rightToLeft' },
},

generateAnchors: false,
// gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
// The setting is only kept for backward compatibility purposes.
Expand Down
5 changes: 4 additions & 1 deletion packages/block-editor/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { Platform } from '@wordpress/element';
*
* @see https://github.com/WordPress/gutenberg/pull/46131
*/
const privateSettings = [ 'inserterMediaCategories' ];
const privateSettings = [
'inserterMediaCategories',
'blockInspectorAnimation',
];

/**
* Action that updates the block editor settings and
Expand Down
32 changes: 0 additions & 32 deletions packages/block-library/src/navigation-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,35 +371,3 @@ function register_block_core_navigation_link() {
);
}
add_action( 'init', 'register_block_core_navigation_link' );

/**
* Enables animation of the block inspector for the Navigation Link block.
*
* See:
* - https://github.com/WordPress/gutenberg/pull/46342
* - https://github.com/WordPress/gutenberg/issues/45884
*
* @param array $settings Default editor settings.
* @return array Filtered editor settings.
*/
function block_core_navigation_link_enable_inspector_animation( $settings ) {
$current_animation_settings = _wp_array_get(
$settings,
array( '__experimentalBlockInspectorAnimation' ),
array()
);

$settings['__experimentalBlockInspectorAnimation'] = array_merge(
$current_animation_settings,
array(
'core/navigation-link' =>
array(
'enterDirection' => 'rightToLeft',
),
)
);

return $settings;
}

add_filter( 'block_editor_settings_all', 'block_core_navigation_link_enable_inspector_animation' );
32 changes: 0 additions & 32 deletions packages/block-library/src/navigation-submenu/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,35 +289,3 @@ function register_block_core_navigation_submenu() {
);
}
add_action( 'init', 'register_block_core_navigation_submenu' );

/**
* Enables animation of the block inspector for the Navigation Submenu block.
*
* See:
* - https://github.com/WordPress/gutenberg/pull/46342
* - https://github.com/WordPress/gutenberg/issues/45884
*
* @param array $settings Default editor settings.
* @return array Filtered editor settings.
*/
function block_core_navigation_submenu_enable_inspector_animation( $settings ) {
$current_animation_settings = _wp_array_get(
$settings,
array( '__experimentalBlockInspectorAnimation' ),
array()
);

$settings['__experimentalBlockInspectorAnimation'] = array_merge(
$current_animation_settings,
array(
'core/navigation-submenu' =>
array(
'enterDirection' => 'rightToLeft',
),
)
);

return $settings;
}

add_filter( 'block_editor_settings_all', 'block_core_navigation_submenu_enable_inspector_animation' );
32 changes: 0 additions & 32 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,35 +874,3 @@ function block_core_navigation_typographic_presets_backcompatibility( $parsed_bl
}

add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_backcompatibility' );

/**
* Enables animation of the block inspector for the Navigation block.
*
* See:
* - https://github.com/WordPress/gutenberg/pull/46342
* - https://github.com/WordPress/gutenberg/issues/45884
*
* @param array $settings Default editor settings.
* @return array Filtered editor settings.
*/
function block_core_navigation_enable_inspector_animation( $settings ) {
$current_animation_settings = _wp_array_get(
$settings,
array( '__experimentalBlockInspectorAnimation' ),
array()
);

$settings['__experimentalBlockInspectorAnimation'] = array_merge(
$current_animation_settings,
array(
'core/navigation' =>
array(
'enterDirection' => 'leftToRight',
),
)
);

return $settings;
}

add_filter( 'block_editor_settings_all', 'block_core_navigation_enable_inspector_animation' );
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const EMPTY_BLOCKS_LIST = [];

const BLOCK_EDITOR_SETTINGS = [
'__experimentalBlockDirectory',
'__experimentalBlockInspectorAnimation',
'__experimentalDiscussionSettings',
'__experimentalFeatures',
'__experimentalGlobalStylesBaseStyles',
Expand Down

0 comments on commit 42cf442

Please sign in to comment.