Skip to content

Commit

Permalink
prep build 07/02
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jul 2, 2024
2 parents 0ea063a + 96bdfcf commit 0ee0eeb
Show file tree
Hide file tree
Showing 83 changed files with 2,787 additions and 700 deletions.
8 changes: 8 additions & 0 deletions docs/reference-guides/block-api/block-supports.md
Original file line number Diff line number Diff line change
Expand Up @@ -1110,3 +1110,11 @@ attributes: {
}
}
```

## splitting

When set to `true`, `Enter` will split the block into two blocks. Note that this
is only meant for simple text blocks such as paragraphs and headings with a
single `RichText` field. RichText in the `edit` function _must_ have an
`identifier` prop that matches the attribute key of the text, so that it updates
the selection correctly and we know where to split.
62 changes: 59 additions & 3 deletions lib/experimental/posts/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,78 @@

add_action( 'admin_menu', 'gutenberg_replace_posts_dashboard' );

// Default to is-fullscreen-mode to avoid jumps in the UI.
add_filter(
'admin_body_class',
static function ( $classes ) {
return "$classes is-fullscreen-mode";
}
);

/**
* Renders the new posts dashboard page.
*/
function gutenberg_posts_dashboard() {
$block_editor_context = new WP_Block_Editor_Context( array( 'name' => 'core/edit-site' ) );
$custom_settings = array(
'siteUrl' => site_url(),
'styles' => get_block_editor_theme_styles(),
'supportsLayout' => wp_theme_has_theme_json(),
);

$editor_settings = get_block_editor_settings( $custom_settings, $block_editor_context );
$active_global_styles_id = WP_Theme_JSON_Resolver::get_user_global_styles_post_id();
$active_theme = get_stylesheet();

$preload_paths = array(
array( '/wp/v2/media', 'OPTIONS' ),
'/wp/v2/types?context=view',
'/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit',
'/wp/v2/global-styles/' . $active_global_styles_id,
'/wp/v2/global-styles/themes/' . $active_theme,
);
block_editor_rest_api_preload( $preload_paths, $block_editor_context );

// Preload server-registered block schemas.
wp_add_inline_script(
'wp-blocks',
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
);

/** This action is documented in wp-admin/edit-form-blocks.php */
do_action( 'enqueue_block_editor_assets' );
wp_register_style(
'wp-gutenberg-posts-dashboard',
gutenberg_url( 'build/edit-site/posts.css', __FILE__ ),
array( 'wp-components', 'wp-commands' )
array( 'wp-components', 'wp-commands', 'wp-edit-site' )
);
wp_enqueue_style( 'wp-gutenberg-posts-dashboard' );
wp_add_inline_script( 'wp-edit-site', 'window.wp.editSite.initializePostsDashboard( "gutenberg-posts-dashboard" );', 'after' );
wp_add_inline_script(
'wp-edit-site',
sprintf(
'wp.domReady( function() {
wp.editSite.initializePostsDashboard( "gutenberg-posts-dashboard", %s );
} );',
wp_json_encode( $editor_settings )
)
);
wp_enqueue_script( 'wp-edit-site' );

wp_enqueue_media();
echo '<div id="gutenberg-posts-dashboard"></div>';
}

/**
* Redirects to the new posts dashboard page and adds the postType query arg.
*/
function gutenberg_add_post_type_arg() {
global $pagenow;
if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'gutenberg-posts-dashboard' === $_GET['page'] && empty( $_GET['postType'] ) ) {
wp_redirect( admin_url( '/admin.php?page=gutenberg-posts-dashboard&postType=post' ) );
exit;
}
}
add_action( 'admin_init', 'gutenberg_add_post_type_arg' );

/**
* Replaces the default posts menu item with the new posts dashboard.
*/
Expand Down
31 changes: 17 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions packages/block-editor/src/components/block-rename/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Modal,
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { useState, useId } from '@wordpress/element';
import { useState } from '@wordpress/element';
import { speak } from '@wordpress/a11y';

/**
Expand All @@ -27,7 +27,6 @@ export default function BlockRenameModal( {
hasOverridesWarning,
} ) {
const [ editedBlockName, setEditedBlockName ] = useState( blockName );
const descriptionId = useId();

const nameHasChanged = editedBlockName !== blockName;
const nameIsOriginal = editedBlockName === originalBlockName;
Expand Down Expand Up @@ -65,7 +64,6 @@ export default function BlockRenameModal( {
onRequestClose={ onClose }
overlayClassName="block-editor-block-rename-modal"
focusOnMount="firstContentElement"
aria={ { describedby: descriptionId } }
size="small"
>
<form
Expand All @@ -79,16 +77,12 @@ export default function BlockRenameModal( {
handleSubmit();
} }
>
<p id={ descriptionId }>
{ __( 'Enter a custom name for this block.' ) }
</p>
<VStack spacing="3">
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
value={ editedBlockName }
label={ __( 'Block name' ) }
hideLabelFromVision
label={ __( 'Name' ) }
help={
hasOverridesWarning
? __(
Expand Down
106 changes: 24 additions & 82 deletions packages/block-editor/src/components/font-appearance-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,12 @@
*/
import { CustomSelectControl } from '@wordpress/components';
import { useMemo } from '@wordpress/element';
import { __, _x, sprintf } from '@wordpress/i18n';

const FONT_STYLES = [
{
name: _x( 'Regular', 'font style' ),
value: 'normal',
},
{
name: _x( 'Italic', 'font style' ),
value: 'italic',
},
];

const FONT_WEIGHTS = [
{
name: _x( 'Thin', 'font weight' ),
value: '100',
},
{
name: _x( 'Extra Light', 'font weight' ),
value: '200',
},
{
name: _x( 'Light', 'font weight' ),
value: '300',
},
{
name: _x( 'Regular', 'font weight' ),
value: '400',
},
{
name: _x( 'Medium', 'font weight' ),
value: '500',
},
{
name: _x( 'Semi Bold', 'font weight' ),
value: '600',
},
{
name: _x( 'Bold', 'font weight' ),
value: '700',
},
{
name: _x( 'Extra Bold', 'font weight' ),
value: '800',
},
{
name: _x( 'Black', 'font weight' ),
value: '900',
},
];
import { __, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';

/**
* Adjusts font appearance field label in case either font styles or weights
Expand All @@ -76,7 +31,7 @@ const getFontAppearanceLabel = ( hasFontStyles, hasFontWeights ) => {
};

/**
* Control to display unified font style and weight options.
* Control to display font style and weight options of the active font.
*
* @param {Object} props Component props.
*
Expand All @@ -87,6 +42,7 @@ export default function FontAppearanceControl( props ) {
onChange,
hasFontStyles = true,
hasFontWeights = true,
fontFamilyFaces,
value: { fontStyle, fontWeight },
...otherProps
} = props;
Expand All @@ -97,43 +53,22 @@ export default function FontAppearanceControl( props ) {
name: __( 'Default' ),
style: { fontStyle: undefined, fontWeight: undefined },
};
const { fontStyles, fontWeights, combinedStyleAndWeightOptions } =
getFontStylesAndWeights( fontFamilyFaces );

// Combines both font style and weight options into a single dropdown.
// Generates select options for combined font styles and weights.
const combineOptions = () => {
const combinedOptions = [ defaultOption ];

FONT_STYLES.forEach( ( { name: styleName, value: styleValue } ) => {
FONT_WEIGHTS.forEach(
( { name: weightName, value: weightValue } ) => {
const optionName =
styleValue === 'normal'
? weightName
: sprintf(
/* translators: 1: Font weight name. 2: Font style name. */
__( '%1$s %2$s' ),
weightName,
styleName
);

combinedOptions.push( {
key: `${ styleValue }-${ weightValue }`,
name: optionName,
style: {
fontStyle: styleValue,
fontWeight: weightValue,
},
} );
}
);
} );

if ( combinedStyleAndWeightOptions ) {
combinedOptions.push( ...combinedStyleAndWeightOptions );
}
return combinedOptions;
};

// Generates select options for font styles only.
const styleOptions = () => {
const combinedOptions = [ defaultOption ];
FONT_STYLES.forEach( ( { name, value } ) => {
fontStyles.forEach( ( { name, value } ) => {
combinedOptions.push( {
key: value,
name,
Expand All @@ -146,7 +81,7 @@ export default function FontAppearanceControl( props ) {
// Generates select options for font weights only.
const weightOptions = () => {
const combinedOptions = [ defaultOption ];
FONT_WEIGHTS.forEach( ( { name, value } ) => {
fontWeights.forEach( ( { name, value } ) => {
combinedOptions.push( {
key: value,
name,
Expand All @@ -158,12 +93,19 @@ export default function FontAppearanceControl( props ) {

// Map font styles and weights to select options.
const selectOptions = useMemo( () => {
// Display combined available font style and weight options.
if ( hasFontStyles && hasFontWeights ) {
return combineOptions();
}

// Display only font style options or font weight options.
return hasFontStyles ? styleOptions() : weightOptions();
}, [ props.options ] );
}, [
props.options,
fontStyles,
fontWeights,
combinedStyleAndWeightOptions,
] );

// Find current selection by comparing font style & weight against options,
// and fall back to the Default option if there is no matching option.
Expand Down
Loading

0 comments on commit 0ee0eeb

Please sign in to comment.