Skip to content
Merged
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
37 changes: 21 additions & 16 deletions packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,21 @@ import {
getPositionClassName,
} from './shared';

/**
* Module Constants
*/

const INNER_BLOCKS_TEMPLATE = [
[
'core/paragraph',
{
align: 'center',
fontSize: 'large',
placeholder: __( 'Write title…' ),
},
],
];

const { __Visualizer: BoxControlVisualizer } = BoxControl;

function getInnerBlocksTemplate( attributes ) {
return [
[
'core/paragraph',
{
align: 'center',
placeholder: __( 'Write title…' ),
...attributes,
},
],
];
}

function retrieveFastAverageColor() {
if ( ! retrieveFastAverageColor.fastAverageColor ) {
retrieveFastAverageColor.fastAverageColor = new FastAverageColor();
Expand Down Expand Up @@ -603,12 +601,19 @@ function CoverEdit( {

const ref = useRef();
const blockProps = useBlockProps( { ref } );

// Check for fontSize support before we pass a fontSize attribute to the innerBlocks.
const hasFontSizes = !! useSetting( 'typography.fontSizes' )?.length;
const innerBlocksTemplate = getInnerBlocksTemplate( {
fontSize: hasFontSizes ? 'large' : undefined,
} );

const innerBlocksProps = useInnerBlocksProps(
{
className: 'wp-block-cover__inner-container',
},
{
template: INNER_BLOCKS_TEMPLATE,
template: innerBlocksTemplate,
templateInsertUpdatesSelection: true,
}
);
Expand Down