AuthorMetaControl.js
3 years ago
CommentsControl.js
4 years ago
ContentTypeControl.js
4 years ago
DynamicSourceControl.js
3 years ago
ExcerptControl.js
4 years ago
LinkTypeControl.js
3 years ago
PostDateControl.js
4 years ago
PostMetaControl.js
3 years ago
TermsControl.js
4 years ago
ExcerptControl.js
43 lines
| 1 | import { ToggleControl } from '@wordpress/components'; |
| 2 | import { __ } from '@wordpress/i18n'; |
| 3 | import NumberControl from '../../../components/number-control'; |
| 4 | import DebouncedTextControl from '../../../components/debounced-text-control'; |
| 5 | |
| 6 | export default function ExcerptControl( props ) { |
| 7 | const { |
| 8 | isActive, |
| 9 | useDefaultMoreLink, |
| 10 | customMoreLinkText, |
| 11 | setAttributes, |
| 12 | } = props; |
| 13 | |
| 14 | return ( |
| 15 | <> |
| 16 | { isActive && |
| 17 | <> |
| 18 | <NumberControl |
| 19 | { ...props } |
| 20 | label={ __( 'Excerpt length', 'generateblocks' ) } |
| 21 | attributeName="excerptLength" |
| 22 | min="0" |
| 23 | /> |
| 24 | |
| 25 | <ToggleControl |
| 26 | label={ __( 'Use default more link', 'generateblocks' ) } |
| 27 | checked={ !! useDefaultMoreLink } |
| 28 | onChange={ ( value ) => setAttributes( { useDefaultMoreLink: value } ) } |
| 29 | /> |
| 30 | |
| 31 | { ! useDefaultMoreLink && |
| 32 | <DebouncedTextControl |
| 33 | label={ __( 'Custom more link text', 'generateblocks' ) } |
| 34 | value={ customMoreLinkText } |
| 35 | onChange={ ( value ) => setAttributes( { customMoreLinkText: value } ) } |
| 36 | /> |
| 37 | } |
| 38 | </> |
| 39 | } |
| 40 | </> |
| 41 | ); |
| 42 | } |
| 43 |