Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/add-reusable-keyword-to-patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks authored Jul 12, 2023
2 parents a9da70c + 56defb4 commit a8b0ddd
Show file tree
Hide file tree
Showing 80 changed files with 1,257 additions and 271 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Add a user’s avatar. ([Source](https://github.com/WordPress/gutenberg/tree/tru

## Pattern

Create and save content to reuse across your site. Update the block, and the changes apply everywhere it’s used. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/block))
Create and save content to reuse across your site. Update the pattern, and the changes apply everywhere it’s used. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/block))

- **Name:** core/block
- **Category:** reusable
Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.3/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function gutenberg_rename_reusable_block_cpt_to_pattern( $args, $post_type ) {
$args['labels']['singular_name'] = _x( 'Pattern', 'post type singular name' );
$args['labels']['add_new_item'] = __( 'Add new Pattern' );
$args['labels']['new_item'] = __( 'New Pattern' );
$args['labels']['edit_item'] = __( 'Edit Pattern' );
$args['labels']['edit_item'] = __( 'Edit Block Pattern' );
$args['labels']['view_item'] = __( 'View Pattern' );
$args['labels']['view_items'] = __( 'View Patterns' );
$args['labels']['all_items'] = __( 'All Patterns' );
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

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

17 changes: 13 additions & 4 deletions packages/block-editor/src/components/block-draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,25 @@ const BlockDraggable = ( {
} ) => {
const { srcRootClientId, isDraggable, icon } = useSelect(
( select ) => {
const { canMoveBlocks, getBlockRootClientId, getBlockName } =
select( blockEditorStore );
const { getBlockType } = select( blocksStore );
const {
canMoveBlocks,
getBlockRootClientId,
getBlockName,
getBlockAttributes,
} = select( blockEditorStore );
const { getBlockType, getActiveBlockVariation } =
select( blocksStore );
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
const blockName = getBlockName( clientIds[ 0 ] );
const variation = getActiveBlockVariation(
blockName,
getBlockAttributes( clientIds[ 0 ] )
);

return {
srcRootClientId: rootClientId,
isDraggable: canMoveBlocks( clientIds, rootClientId ),
icon: getBlockType( blockName )?.icon,
icon: variation?.icon || getBlockType( blockName )?.icon,
};
},
[ clientIds ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ function useHasTextColumnsControl( settings ) {
return settings?.typography?.textColumns;
}

function getUniqueFontSizesBySlug( settings ) {
const fontSizesPerOrigin = settings?.typography?.fontSizes ?? {};
const fontSizes = []
.concat( fontSizesPerOrigin?.custom ?? [] )
.concat( fontSizesPerOrigin?.theme ?? [] )
.concat( fontSizesPerOrigin.default ?? [] );

return fontSizes.reduce( ( acc, currentSize ) => {
if ( ! acc.some( ( { slug } ) => slug === currentSize.slug ) ) {
acc.push( currentSize );
}
return acc;
}, [] );
}

function TypographyToolsPanel( {
resetAllFilter,
onChange,
Expand Down Expand Up @@ -189,11 +204,8 @@ export default function TypographyPanel( {
// Font Size
const hasFontSizeEnabled = useHasFontSizeControl( settings );
const disableCustomFontSizes = ! settings?.typography?.customFontSize;
const fontSizesPerOrigin = settings?.typography?.fontSizes ?? {};
const fontSizes = []
.concat( fontSizesPerOrigin?.custom ?? [] )
.concat( fontSizesPerOrigin?.theme ?? [] )
.concat( fontSizesPerOrigin.default ?? [] );
const fontSizes = getUniqueFontSizesBySlug( settings );

const fontSize = decodeValue( inheritedValue?.typography?.fontSize );
const setFontSize = ( newValue, metadata ) => {
const actualValue = !! metadata?.slug
Expand Down
8 changes: 7 additions & 1 deletion packages/block-editor/src/components/link-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ $preview-image-height: 140px;
// Inline block required to preserve white space
// between `<mark>` elements and text nodes.
display: inline-block;

mark {
font-weight: 600;
color: inherit;
background-color: transparent;
}
}

.components-menu-item__shortcut {
Expand Down Expand Up @@ -213,7 +219,7 @@ $preview-image-height: 140px;
position: relative;

mark {
font-weight: 700;
font-weight: 600;
color: inherit;
background-color: transparent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,28 @@ export default function useBlockDisplayInformation( clientId ) {
return useSelect(
( select ) => {
if ( ! clientId ) return null;
const { getBlockName, getBlockAttributes } =
select( blockEditorStore );
const {
getBlockName,
getBlockAttributes,
__experimentalGetReusableBlockTitle,
} = select( blockEditorStore );
const { getBlockType, getActiveBlockVariation } =
select( blocksStore );
const blockName = getBlockName( clientId );
const blockType = getBlockType( blockName );
if ( ! blockType ) return null;
const attributes = getBlockAttributes( clientId );
const match = getActiveBlockVariation( blockName, attributes );
const isSynced =
isReusableBlock( blockType ) || isTemplatePart( blockType );
const isReusable = isReusableBlock( blockType );
const resusableTitle = isReusable
? __experimentalGetReusableBlockTitle( attributes.ref )
: undefined;
const title = resusableTitle || blockType.title;
const isSynced = isReusable || isTemplatePart( blockType );
const positionLabel = getPositionTypeLabel( attributes );
const blockTypeInfo = {
isSynced,
title: blockType.title,
title,
icon: blockType.icon,
description: blockType.description,
anchor: attributes?.anchor,
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/avatar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const AvatarInspectorControls = ( {
<PanelBody title={ __( 'Settings' ) }>
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Image size' ) }
onChange={ ( newSize ) =>
setAttributes( {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/block/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"name": "core/block",
"title": "Pattern",
"category": "reusable",
"description": "Create and save content to reuse across your site. Update the block, and the changes apply everywhere it’s used.",
"keywords": [ "reusable" ],
"description": "Create and save content to reuse across your site. Update the pattern, and the changes apply everywhere it’s used.",
"keywords": [ "reusable" ],
"textdomain": "default",
"attributes": {
"ref": {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function ColumnsEditContainer( {
<>
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Columns' ) }
value={ count }
onChange={ ( value ) =>
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/comment-author-avatar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function Edit( {
<PanelBody title={ __( 'Avatar Settings' ) }>
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Image size' ) }
onChange={ ( newWidth ) =>
setAttributes( {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/file/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function FileBlockInspector( {
{ displayPreview && (
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Height in pixels' ) }
min={ MIN_PREVIEW_HEIGHT }
max={ Math.max(
Expand Down
36 changes: 21 additions & 15 deletions packages/block-library/src/footnotes/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,30 @@ export const format = {
} = useSelect( blockEditorStore );
const { selectionChange, insertBlock } =
useDispatch( blockEditorStore );

function onClick() {
registry.batch( () => {
const id = createId();
const newValue = insertObject(
value,
{
type: formatName,
attributes: {
'data-fn': id,
let id;
if ( isObjectActive ) {
const object = value.replacements[ value.start ];
id = object?.attributes?.[ 'data-fn' ];
} else {
id = createId();
const newValue = insertObject(
value,
{
type: formatName,
attributes: {
'data-fn': id,
},
innerHTML: `<a href="#${ id }" id="${ id }-link">*</a>`,
},
innerHTML: `<a href="#${ id }" id="${ id }-link">*</a>`,
},
value.end,
value.end
);
newValue.start = newValue.end - 1;

onChange( newValue );
value.end,
value.end
);
newValue.start = newValue.end - 1;
onChange( newValue );
}

// BFS search to find the first footnote block.
let fnBlock = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ function GalleryEdit( props ) {
max={ Math.min( MAX_COLUMNS, images.length ) }
{ ...MOBILE_CONTROL_PROPS_RANGE_CONTROL }
required
size="__unstable-large"
__next40pxDefaultSize
/>
) }
<ToggleControl
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/latest-comments/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default function LatestComments( { attributes, setAttributes } ) {
/>
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Number of comments' ) }
value={ commentsToShow }
onChange={ ( value ) =>
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
displayPostContentRadio === 'excerpt' && (
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Max number of words' ) }
value={ excerptLength }
onChange={ ( value ) =>
Expand Down Expand Up @@ -359,6 +360,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
{ postLayout === 'grid' && (
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Columns' ) }
value={ columns }
onChange={ ( value ) =>
Expand Down
Loading

0 comments on commit a8b0ddd

Please sign in to comment.