/** * External dependencies */ import clsx from 'clsx'; /** * WordPress dependencies */ import { getActiveFormat, toggleFormat } from '@wordpress/rich-text'; import { ToolbarDropdownMenu, MenuGroup, MenuItem } from '@wordpress/components'; import { BlockFormatControls } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { textColor as icon } from '@wordpress/icons'; /** * Internal dependencies */ import { registerFormatType } from './register-format-type'; import type { FormatEditProps } from './types'; const label = __( 'Font size', 'richtext-extension' ); rtexConf.fontSize.forEach( ( { title, className }, index ) => { registerFormatType( 'rtex/' + className, { title, tagName: 'span', className, ...( index === 0 && { edit: ( { value, onChange }: FormatEditProps ) => { const hasActive = rtexConf.fontSize.some( ( item ) => !! getActiveFormat( value, 'rtex/' + item.className ) ); return ( { ( { onClose } ) => ( { rtexConf.fontSize.map( ( item ) => { const formatName = 'rtex/' + item.className; const isSelected = !! getActiveFormat( value, formatName ); return ( { onClose(); onChange( toggleFormat( value, { type: formatName } ) ); } } > { item.title } ); } ) } ) } ); }, } ), } ); } );