How to use the @wordpress/block-editor.withFontSizes function in @wordpress/block-editor

To help you get started, we’ve selected a few @wordpress/block-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / wordpress__block-editor / wordpress__block-editor-tests.tsx View on Github external
//
// font-sizes
//

// $ExpectType Partial & Pick
be.getFontSize(FONT_SIZES, 'small', 15);

// $ExpectType Partial & Pick
be.getFontSize(FONT_SIZES, undefined, 15);

// $ExpectType string
be.getFontSizeClass('foo');

// $ExpectType ComponentType
be.withFontSizes('fontSize')(() =&gt; <h1>Hello World</h1>);

//
// inner-blocks
//
;
;
;
;

//
// inserter
//
;
;

//
github ampproject / amp-wp / assets / src / stories-editor / components / higher-order / with-amp-story-settings.js View on Github external
bringForward: () => moveBlocksDown( clientId, rootClientId ),
		sendBackward: () => moveBlocksUp( clientId, rootClientId ),
		moveFront: () => {
			const blockOrder = getBlockOrder( rootClientId );
			const topIndex = blockOrder.length - 1;
			moveBlockToPosition( clientId, rootClientId, rootClientId, topIndex );
		},
		moveBack: () => {
			moveBlockToPosition( clientId, rootClientId, rootClientId, 0 );
		},
	};
} );

const enhance = compose(
	withColors( 'backgroundColor', { textColor: 'color' } ),
	withFontSizes( 'fontSize' ),
	applyFallbackStyles,
	applyWithSelect,
	applyWithDispatch,
);

export default createHigherOrderComponent(
	( BlockEdit ) => {
		return enhance( ( props ) => { // eslint-disable-line complexity
			const {
				clientId,
				rootClientId,
				name,
				attributes,
				isLast,
				isFirst,
				currentBlockPosition,
github godaddy-wordpress / coblocks / src / blocks / highlight / edit.js View on Github external
style={ {
							backgroundColor: backgroundColor &amp;&amp; backgroundColor.color,
							color: textColor &amp;&amp; textColor.color,
							fontSize: fontSize &amp;&amp; fontSize.size ? fontSize.size + 'px' : undefined,
						} }
						keepPlaceholderOnFocus
					/&gt;
				<p></p>
			
		);
	}
}

export default compose( [
	applyWithColors,
	withFontSizes( 'fontSize' ),
] )( Edit );
github godaddy-wordpress / coblocks / src / blocks / author / edit.js View on Github external
}

const applyWithSelect = withSelect( () => {
	const selectedClientId = select( 'core/block-editor' ).getBlockSelectionStart();
	const parentClientId = select( 'core/block-editor' ).getBlockRootClientId(
		selectedClientId
	);

	return {
		selectedParentClientId: parentClientId,
	};
} );

export default compose( [
	withColors( 'backgroundColor', { textColor: 'color' } ),
	withFontSizes( 'fontSize' ),
	applyWithSelect,
] )( AuthorEdit );
github Automattic / wp-calypso / apps / full-site-editing / full-site-editing-plugin / full-site-editing / blocks / site-title / edit.js View on Github external
onSplit={ noop }
				placeholder={ __( 'Add a Site Title' ) }
				style={ {
					color: textColor.color,
					fontSize: actualFontSize ? actualFontSize + 'px' : undefined,
				} }
				tagName="h1"
				value={ value }
			/&gt;
		
	);
}

export default compose( [
	withColors( { textColor: 'color' } ),
	withFontSizes( 'fontSize' ),
	withSelect( ( select, { clientId } ) =&gt; {
		const { getBlockIndex, getBlockRootClientId, getTemplateLock } = select( 'core/block-editor' );
		const rootClientId = getBlockRootClientId( clientId );

		return {
			blockIndex: getBlockIndex( clientId, rootClientId ),
			isLocked: !! getTemplateLock( rootClientId ),
			rootClientId,
		};
	} ),
	withDispatch( ( dispatch, { blockIndex, rootClientId } ) =&gt; ( {
		insertDefaultBlock: () =&gt;
			dispatch( 'core/block-editor' ).insertDefaultBlock( {}, rootClientId, blockIndex + 1 ),
	} ) ),
	withSiteOptions( {
		siteTitle: { optionName: 'title', defaultValue: __( 'Site title loading…' ) },
github godaddy-wordpress / coblocks / src / blocks / author / inspector.js View on Github external
backgroundColor: backgroundColor.color,
								fallbackTextColor,
								fallbackBackgroundColor,
							} }
							fontSize={ fontSize.size }
						/&gt;
					
				
			
		);
	}
}

export default compose( [
	withColors( 'backgroundColor', { textColor: 'color' } ),
	withFontSizes( 'fontSize' ),
	applyFallbackStyles,
] )( Inspector );
github godaddy-wordpress / coblocks / src / blocks / gallery-stacked / inspector.js View on Github external
onChange={ setFontSize }
						/&gt;
					}

				
				
			
		);
	}
}

export default compose( [
	withSelect( ( select ) =&gt; ( {
		wideControlsEnabled: select( 'core/editor' ).getEditorSettings().alignWide,
	} ) ),
	withFontSizes( 'fontSize' ),
] )( Inspector );
github Automattic / wp-calypso / apps / full-site-editing / full-site-editing-plugin / full-site-editing / blocks / navigation-menu / edit.js View on Github external
fontSize={ actualFontSize }
					/&gt;
				
			
			
		
	);
};

export default compose( [
	withColors( 'backgroundColor', { textColor: 'color' } ),
	withFontSizes( 'fontSize' ),
	withSelect( select =&gt; {
		return {
			isPublished: select( 'core/editor' ).isCurrentPostPublished(),
		};
	} ),
] )( NavigationMenuEdit );
github ampproject / amp-wp / assets / src / blocks / amp-story-text / edit.js View on Github external
[ backgroundColor.class ]: backgroundColor.class,
							[ textColor.class ]: textColor.class,
							[ fontSize.class ]: autoFontSize ? undefined : fontSize.class,
							'amp-story__has-rounded-corners': ampRoundedCorners,
						} ) }
						placeholder={ placeholder || __( 'Write text…', 'amp' ) }
					/&gt;
				
			
		);
	}
}

export default compose(
	withColors( 'backgroundColor', { textColor: 'color' } ),
	withFontSizes( 'fontSize' ),
	applyFallbackStyles
)( TextBlockEdit );
github godaddy-wordpress / coblocks / src / blocks / highlight / inspector.js View on Github external
textColor: textColor.color,
								backgroundColor: backgroundColor.color,
								fallbackBackgroundColor,
								fallbackTextColor,
							} }
						/&gt;
					
				
			
		);
	}
}

export default compose( [
	applyWithColors,
	withFontSizes( 'fontSize' ),
] )( Inspector );