/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/read-more/edit.js
73 строки
2 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { InspectorControls, RichText, useBlockProps, } from '@wordpress/block-editor'; import { ToggleControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; export default function ReadMore( { attributes: { content, linkTarget }, setAttributes, insertBlocksAfter, } ) { const blockProps = useBlockProps(); const dropdownMenuProps = useToolsPanelDropdownMenuProps(); return ( <> <InspectorControls> <ToolsPanel label={ __( 'Settings' ) } resetAll={ () => setAttributes( { linkTarget: '_self' } ) } dropdownMenuProps={ dropdownMenuProps } > <ToolsPanelItem label={ __( 'Open in new tab' ) } isShownByDefault hasValue={ () => linkTarget !== '_self' } onDeselect={ () => setAttributes( { linkTarget: '_self' } ) } > <ToggleControl label={ __( 'Open in new tab' ) } onChange={ ( value ) => setAttributes( { linkTarget: value ? '_blank' : '_self', } ) } checked={ linkTarget === '_blank' } /> </ToolsPanelItem> </ToolsPanel> </InspectorControls> <RichText identifier="content" tagName="a" aria-label={ __( '“Read more” link text' ) } placeholder={ __( 'Read more' ) } value={ content } onChange={ ( newValue ) => setAttributes( { content: newValue } ) } __unstableOnSplitAtEnd={ insertBlocksAfter ? () => insertBlocksAfter( createBlock( getDefaultBlockName() ) ) : undefined } withoutInteractiveFormatting { ...blockProps } /> </> ); }