/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/post-comment/edit.js
44 строки
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { __, _x } from '@wordpress/i18n'; import { Placeholder, TextControl, Button } from '@wordpress/components'; import { useState } from '@wordpress/element'; import { blockDefault } from '@wordpress/icons'; import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor'; export default function Edit( { attributes: { commentId }, setAttributes } ) { const [ commentIdInput, setCommentIdInput ] = useState( commentId ); const blockProps = useBlockProps(); const innerBlocksProps = useInnerBlocksProps( blockProps ); if ( ! commentId ) { return ( <div { ...blockProps }> <Placeholder icon={ blockDefault } label={ _x( 'Post Comment', 'block title' ) } instructions={ __( 'To show a comment, input the comment ID.' ) } > <TextControl value={ commentId } onChange={ ( val ) => setCommentIdInput( parseInt( val ) ) } /> <Button __next40pxDefaultSize variant="primary" onClick={ () => { setAttributes( { commentId: commentIdInput } ); } } > { __( 'Save' ) } </Button> </Placeholder> </div> ); } return <div { ...innerBlocksProps } />; }