/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/widgets/src/blocks/widget-group/edit.js
62 строки
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { useBlockProps, BlockIcon, ButtonBlockAppender, InnerBlocks, store as blockEditorStore, RichText, } from '@wordpress/block-editor'; import { Placeholder } from '@wordpress/components'; import { group as groupIcon } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; export default function Edit( props ) { const { clientId } = props; const hasInnerBlocks = useSelect( ( select ) => select( blockEditorStore ).getBlockCount( clientId ) > 0, [ clientId ] ); return ( <div { ...useBlockProps( { className: 'widget' } ) }> { ! hasInnerBlocks ? ( <PlaceholderContent { ...props } /> ) : ( <PreviewContent { ...props } /> ) } </div> ); } function PlaceholderContent( { clientId } ) { return ( <> <Placeholder className="wp-block-widget-group__placeholder" icon={ <BlockIcon icon={ groupIcon } /> } label={ __( 'Widget Group' ) } > <ButtonBlockAppender rootClientId={ clientId } /> </Placeholder> <InnerBlocks renderAppender={ false } /> </> ); } function PreviewContent( { attributes, setAttributes } ) { return ( <> <RichText tagName="h2" identifier="title" className="widget-title" allowedFormats={ [] } placeholder={ __( 'Title' ) } value={ attributes.title ?? '' } onChange={ ( title ) => setAttributes( { title } ) } /> <InnerBlocks /> </> ); }